part of 'app_routers.dart';

extension AppPages on AppRouters {
  ///页面初始路由页面
  static String get initialRoute {
    if (userManager.isFirstLogin) return AppRouters.welcome.r;
    if (userManager.isLoggedIn) return AppRouters.mainTab.r;
    return AppRouters.login.r;
  }

  static List<GetPage> pages = AppRouters.values.map((e) => e.page).toList();

  String get r {
    switch (this) {
      default:
        return '/$name';
    }
  }

  GetPage get page {
    switch (this) {
      case AppRouters.login:
        return GetPage(
          name: r,
          page: () => pageWidget,
          binding: BindingsBuilder(() {
            Get.lazyPut<LoginLogic>(() => LoginLogic());
          }),
        );
      case AppRouters.signUp:
      case AppRouters.debug:
        return GetPage(name: r, page: () => pageWidget, transition: Transition.downToUp, fullscreenDialog: true, opaque: false);
      default:
        return GetPage(name: r, page: () => pageWidget);
    }
  }
}
